package controller;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import thread.AtualizationThread;
import beans.Pasta;

public class ThreadsController {
	private static List<AtualizationThread> listaThreads;
	
	public ThreadsController() {
		listaThreads = new ArrayList<AtualizationThread>();
		Set<Pasta> pastas = PastaManager.getListaPastas();
		Iterator<Pasta> it = pastas.iterator();
		
		while(it.hasNext()){
			listaThreads.add(new AtualizationThread(it.next()));
		}
	}
	
	public boolean rmvThread(AtualizationThread t){
		return listaThreads.remove(t);
	}
	
	public boolean addThread(AtualizationThread t){
		return listaThreads.add(t);
	}
	
	public void startTodas(){
		for(int i=0, max = listaThreads.size(); i<max;i++){
			listaThreads.get(i).start();
		}
	}
}
